package com.buba.user.controller;


import com.buba.pojo.other.DivisionType;
import com.buba.pojo.other.HospitalGuide;
import com.buba.pojo.other.PackageYpe;
import com.buba.pojo.other.SetMeal;
import com.buba.pojo.system.Health;
import com.buba.pojo.system.NewsBulletin;
import com.buba.pojo.user.Campus;
import com.buba.pojo.user.Doctor;
import com.buba.pojo.user.User;
import com.buba.user.pojo.CampusVo;
import com.buba.user.pojo.DivisionVo;
import com.buba.user.pojo.DoctorVo;
import com.buba.user.pojo.MealVo;
import com.buba.user.service.impl.DoctorServiceImpl;
import com.buba.utils.R;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 医生表 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-06-09
 */
@Slf4j
@RestController
@RequestMapping("/user/doctor")
public class DoctorController {


    @Autowired
    private DoctorServiceImpl doctorService;

    /*
     * @Author: 张庆威
     * @Description: (根据日期查询医生)
     * @Date: 14:43 2022/6/14
     * @Param: [number]
     * @return: com.buba.utils.R
     **/
    @GetMapping({"/getDoctors/{day}"})
    public R getDoctors(@PathVariable("day") String day) {
        log.info("day==="+day);
        List<Doctor> list = doctorService.getDoctors(day);
        if(list != null){
            return R.ok().data("list",list);
        }else{
            return R.error();
        }
    }

    @ApiOperation(value = "医生管理")
    @GetMapping("/ren/findDoctorAll")
    public R findDoctorAll(){
        List<DoctorVo> list = doctorService.findDoctorAll();
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "添加医生管理")
    @PostMapping("/ren/addDoctor")
    public R addDoctor(@RequestBody DoctorVo doctorVo, Doctor doctor, Campus campus, DivisionType divisionType){
        int i=doctorService.addDoctor(doctorVo,doctor,campus,divisionType);
        if(i>0){
            return R.ok().data("ok","添加成功");
        }else {
            return R.error().data("error","添加失败");
        }
    }
    @ApiOperation(value = "修改医生管理")
    @PostMapping("/ren/updDoctor")
    public R updDoctor(@RequestBody DoctorVo doctorVo,Doctor doctor, Campus campus, DivisionType divisionType){
        int i = doctorService.updDoctor(doctorVo,doctor,campus,divisionType);
        if(i>0){
            return R.ok().data("ok","修改成功");
        }else {
            return R.error().data("error","修改失败");
        }
    }
    @ApiOperation(value = "删除医生管理")
    @PostMapping("/ren/delDoctor")
    public R delDoctor(@RequestBody Doctor doctor){
        int i = doctorService.delDoctor(doctor);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "医生姓名查询")
    @GetMapping("/ren/mhcAdd")
    public R mhcAdd(@RequestParam("doctorName") String doctorName,
                    @RequestParam("divisionName") String divisionName){
        List<DoctorVo> list = doctorService.mhcAdd(doctorName,divisionName);
        return R.ok().data("list",list);
    }



    @ApiOperation(value = "科室管理")
    @GetMapping("/ren/findDivisionAll")
    public R findDivisionAll(){
        List<DivisionVo> list = doctorService.findDivisionAll();
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "添加科室管理")
    @PostMapping("/ren/addDivision")
    public R addDivision(@RequestBody DivisionVo divisionVo){
        int i = doctorService.addDivision(divisionVo);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "修改科室管理")
    @PostMapping("/ren/updDivision")
    public R updDivision(@RequestBody DivisionVo divisionVo, DivisionType divisionType, Campus campus, HospitalGuide hospitalGuide){
        int i = doctorService.updDivision(divisionVo,divisionType,campus,hospitalGuide);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "删除科室管理")
    @PostMapping("/ren/delDepartment")
    public R delDepartment(@RequestBody DivisionType divisionType){
        int i = doctorService.delDepartment(divisionType);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "医生姓名查询")
    @GetMapping("/ren/Depmhc")
    public R Depmhc(@RequestParam("campusName") String campusName,
                    @RequestParam("divisionName") String divisionName){
        List<DivisionVo> list = doctorService.Depmhc(campusName,divisionName);
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "健康百科")
    @GetMapping("/ren/findHealthAll")
    public R findHealthAll(){
        List<Health> list = doctorService.findHealthAll();
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "健康百科添加")
    @PostMapping("/ren/addHealth")
    public R Healthy(@RequestBody Health health){
        int i = doctorService.Healthy(health);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "健康百科修改")
    @PostMapping("/ren/updHealth")
    public R updHealth(@RequestBody Health health){
        int i = doctorService.updHealth(health);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "健康百科修改")
    @PostMapping("/ren/mtkHealth")
    public R mtkHealth(@RequestBody Health health){
        int i = doctorService.mtkHealth(health);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "健康百科修改")
    @GetMapping("/ren/Heamhc")
    public R Heamhc(@RequestParam("htitle") String htitle){
        List<Health> list = doctorService.Heamhc(htitle);
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "医院导航")
    @GetMapping("/ren/findCampusAll")
    public R findCampusAll(){
        List<CampusVo> list = doctorService.findCampusAll();
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "体检套餐")
    @GetMapping("/ren/finMealAll")
    public R finMealAll(){
        List<MealVo> list = doctorService.finMealAll();
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "体检套餐添加")
    @PostMapping("/ren/MealAdd")
    public R MealAdd(@RequestBody MealVo mealVo , SetMeal setMeal, Campus campus , PackageYpe packageYpe){
        int i = doctorService.MealAdd(mealVo,setMeal,campus,packageYpe);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "体检套餐修改")
    @PostMapping("/ren/MealUpd")
    public R MealUpd(@RequestBody MealVo mealVo , SetMeal setMeal, Campus campus , PackageYpe packageYpe){
        int i = doctorService.MealUpd(mealVo,setMeal,campus,packageYpe);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "体检套餐修改")
    @PostMapping("/ren/delMeal")
    public R delMeal(@RequestBody MealVo mealVo){
        int i = doctorService.delMeal(mealVo);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "套餐类型")
    @GetMapping("/ren/findPackAll")
    public R findPackAll(){
        List<PackageYpe> list = doctorService.findPackAll();
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "套餐类型添加")
    @PostMapping("/ren/pkAdd")
    public R pkAdd(@RequestBody PackageYpe packageYpe){
        int i = doctorService.pkAdd(packageYpe);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "套餐类型修改")
    @PostMapping("/ren/pkUpd")
    public R pkUpd(@RequestBody PackageYpe packageYpe){
        int i = doctorService.pkUpd(packageYpe);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "套餐类型删除")
    @PostMapping("/ren/delpk")
    public R delpk(@RequestBody PackageYpe packageYpe){
        int i = doctorService.delpk(packageYpe);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }

    @ApiOperation(value = "套餐类型模糊差")
    @GetMapping("/ren/mhcpy")
    public R lxmhc(@RequestParam("pkName") String pkName){
        List<PackageYpe> list = doctorService.lxmhc(pkName);
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "套餐类型模糊差")
    @GetMapping("/ren/taomtk")
    public R taomtk(@RequestParam("setMealName") String setMealName){
        List<MealVo> list = doctorService.taomtk(setMealName);
        return R.ok().data("list",list);
    }

    @ApiOperation(value = "管理员管理")
    @GetMapping("/ren/findAdminAll")
    public R findAdminAll(){
        List<User> list = doctorService.findAdminAll();
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "管理员管理添加")
    @PostMapping("/ren/AddAdmin")
    public R AddAdmin(@RequestBody User user){
        int i = doctorService.AddAdmin(user);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "管理员管理修改")
    @PostMapping("/ren/UpdAdmin")
    public R UpdAdmin(@RequestBody User user){
        int i = doctorService.UpdAdmin(user);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "套餐类型模糊差")
    @GetMapping("/ren/mhcAdmin")
    public R mhcAdmin(@RequestParam("userName") String userName){
        List<User> list = doctorService.mhcAdmin(userName);
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "套餐类型删除")
    @GetMapping("/ren/shanchu")
    public R shanchu(String id){
        int i = doctorService.shanchu(id);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "公告")
    @GetMapping("/ren/findMessageAll")
    public R findMessageAll(){
        List<NewsBulletin> list = doctorService.findMessageAll();
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "公告添加")
    @PostMapping("/ren/MessageAdd")
    public R MessageAdd(@RequestBody NewsBulletin newsBulletin){
        int i = doctorService.MessageAdd(newsBulletin);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "公告修改")
    @PostMapping("/ren/MessageUpd")
    public R MessageUpd(@RequestBody NewsBulletin newsBulletin){
        int i = doctorService.MessageUpd(newsBulletin);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "公告删除")
    @GetMapping("/ren/MessageDel")
    public R MessageDel(String id){
        int i = doctorService.MessageDel(id);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "标题模糊差")
    @GetMapping("/ren/mhcMessage")
    public R mhcMessage(@RequestParam("newsTitle") String newsTitle){
        List<NewsBulletin> list = doctorService.mhcMessage(newsTitle);
        return R.ok().data("list",list);
    }

    @ApiOperation(value = "公告")
    @GetMapping("/ren/findMessageAlls")
    public R findMessageAlls(){
        List<NewsBulletin> list = doctorService.findMessageAlls();
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "公告添加")
    @PostMapping("/ren/MessageAdds")
    public R MessageAdds(@RequestBody NewsBulletin newsBulletin){
        int i = doctorService.MessageAdds(newsBulletin);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "公告修改")
    @PostMapping("/ren/MessageUpds")
    public R MessageUpds(@RequestBody NewsBulletin newsBulletin){
        int i = doctorService.MessageUpds(newsBulletin);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "公告删除")
    @GetMapping("/ren/MessageDels")
    public R MessageDels(String id){
        int i = doctorService.MessageDels(id);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
    @ApiOperation(value = "标题模糊差")
    @GetMapping("/ren/mhcMessages")
    public R mhcMessages(@RequestParam("newsTitle") String newsTitle){
        List<NewsBulletin> list = doctorService.mhcMessages(newsTitle);
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "修改密码")
    @GetMapping("/ren/mimaUpd/{id}/{password}")
    public R mimaUpd(@PathVariable("id") Integer id,@PathVariable("password") String password){
        int i = doctorService.mimaUpd(id,password);
        if(i>0){
            return R.ok().data("ok","删除成功");
        }else {
            return R.error().data("error","删除失败");
        }
    }
}

